﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ImageResizer
{
    /// <summary>
    /// Formulaire de saisie d'un texte par l'utilisateur
    /// </summary>
    public partial class SingleInput : Form
    {
        #region Public properties
        /// <summary>
        /// Obtient ou défini le label du texte à saisir
        /// </summary>
        public string Label
        {
            get
            {
                return labelDescription.Text;
            }

            set
            {
                labelDescription.Text = value;
            }
        }

        /// <summary>
        /// Obtient ou défini le texte saisi
        /// </summary>
        public string Value
        {
            get
            {
                return textBoxValue.Text;
            }

            set
            {
                textBoxValue.Text = value;
            }
        } 
        #endregion

        #region CTOR
        /// <summary>
        /// CTOR
        /// </summary>
        /// <param name="label">le label</param>
        /// <param name="initialValue">la valeur initial de la saisie</param>
        public SingleInput(string label, string initialValue)
        {
            InitializeComponent();
            Label = label;
            Value = initialValue;
        }

        /// <summary>
        /// CTOR
        /// </summary>
        /// <param name="label">le label</param>
        public SingleInput(string label)
        {
            InitializeComponent();
            Label = label;
        } 
        #endregion

        #region Private methods
        /// <summary>
        /// Gestion du clic sur le bouton OK
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ButtonOkClick(object sender, EventArgs e)
        {
            DialogResult = DialogResult.OK;
            Close();
        }

        /// <summary>
        /// Gestion du clic sur le bouton Cancel
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ButtoCancelClick(object sender, EventArgs e)
        {
            DialogResult = DialogResult.Cancel;
            Close();
        } 
        #endregion
    }
}
